<template>
  <div class="action-footer" >
    <div class="action-bar" :style="{left}"><slot></slot></div>
    <div class="action-bar-stuff"></div>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref,onUnmounted, computed } from 'vue';
const collapsed = ref(false);
const left = computed(()=>{
  return collapsed.value ? '56px' : '200px';
});
onMounted(()=>{
  const state = localStorage.getItem('collapsed') === 'true';
  collapsed.value = state;
})
// 添加全局事件监听器以响应其他组件的状态变更
window.addEventListener('sidebar:collapse-change', (event:any) => {
  if (event.detail && 'collapsed' in event.detail) {
    collapsed.value = event.detail.collapsed;
  }
  console.log('collapsed',collapsed.value);
  
});
// 组件卸载时移除事件监听器
onUnmounted(() => {
  window.removeEventListener('sidebar:collapse-change', () => {});
});
</script>

<style scoped>
.action-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    gap: 16px;
    background-color: #fff;
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 1;
    box-shadow: 0 -2px 8px rgba(29, 35, 41, .05); 
    transition: var(--transition);
}
.action-bar-stuff {
  height: 64px;
  line-height: 64px;
}
</style>